package com.imddy.logtest.log;

import org.apache.log4j.PropertyConfigurator;

import java.util.Enumeration;
import java.util.Properties;
import java.util.ResourceBundle;

public class LogBuilder {
   
	public static Boolean init() {
		System.out.println("LogBuilder---init()...0");
		initLogVar();
		initLog();
		System.out.println("LogBuilder---init()...1");
		return true;
	}

	private static void initLogVar() {
		ResourceBundle resb = ResourceBundle.getBundle("log/log_var_conf");
		Enumeration<String> keys = resb.getKeys();
		while (keys.hasMoreElements()) {
			String key = keys.nextElement();
			String value = resb.getString(key);
			System.setProperty(key, value);
		}
	}
   
	private static void initLog() {
		Properties properties = new Properties();
		ResourceBundle resb = ResourceBundle.getBundle("log/log");
		Enumeration<String> keys = resb.getKeys();
		while (keys.hasMoreElements()) {
			String key = keys.nextElement();
			String value = resb.getString(key);
			properties.put(key, value);
		}
		PropertyConfigurator.configure(properties);
	}
}